Angular Doc API
This is the skeleton of the "@ngdoc" plugin without much of the main logic for the parsing and rendering methods. This gives you an idea of how documents are parsed, rendered, and grouped. For example, the "layout" configuration provides information for how non-overview documentation can be grouped within a module ('directive', 'filter', 'service', 'type').
"use strict"; /*=========== DEPENDENCIES =============*/ var Example = require('./resources/example.js').Example; /*=========== PRIVATE VARIABLES AND METHODS ===========*/ var DOCS_PATH = /^\/(documentation)/; var INDEX_PATH = /^(\/|\/index[^\.]*.html)$/; var GLOBALS = /^angular\.([^\.]+)$/; var MODULE = /^((?:(?!^angular\.)[^\.])+)$/; var MODULE_MOCK = /^angular\.mock\.([^\.]+)$/; var MODULE_DIRECTIVE = /^((?:(?!^angular\.)[^\.])+)\.directive:([^\.]+)$/; var MODULE_DIRECTIVE_INPUT = /^((?:(?!^angular\.)[^\.])+)\.directive:input\.([^\.]+)$/; var MODULE_FILTER = /^((?:(?!^angular\.)[^\.])+)\.filter:([^\.]+)$/; var MODULE_SERVICE = /^((?:(?!^angular\.)[^\.])+)\.\$([^\.]+?)(Provider)?$/; var MODULE_TYPE = /^((?:(?!^angular\.)[^\.])+)\..+\.([A-Z][^\.]+)$/; var DASH_CASE_REGEXP = /[A-Z]/g; var BOOLEAN_ATTR = { 'multiple': true, 'selected': true, 'checked': true, 'disabled': true, 'readOnly': true, 'required': true }; var dashCase = function (name){ ... }; var trim = function (text) { ... }; /*============ EXPORT THE DOC API CONFIGURATION ============*/ module.exports = { identifier: "ngdoc", title: "Angular Documentation", layout: { module:{ title: "module", link: "documentation/angular/guide/module", getModule: function (id, module) { if(id == 'angular.Module'){ return "ng"; } else if (id.match(MODULE_MOCK)) { return "ngMock"; } else if (id.match(GLOBALS)){ return "ng"; } else { return module; } } }, sections:{ "directive":{ order: 1, title: "directive", link: "documentation/angular/guide/directive", match: function (id, module, section, item, subItem) { return (!id.match(MODULE_TYPE)) && section == "directive"; } }, "service": { order: 2, title: "service", link: "documentation/angular/guide/dev_guide.services", match: function (id, module, section, item, subItem) { return id.match(MODULE_SERVICE); } }, "filter":{ order: 3, title: "filter", link: "documentation/angular/guide/dev_guide.templates.filters", match: function (id, module, section, item, subItem) { return id.match(MODULE_FILTER); } }, "type":{ order: 4, title: "Types", link:"documentation/angular/guide/types", match: function (id, module, section, item, subItem) { return id.match(MODULE_TYPE) || id == "angular.IModule"; } }, "global": { order: 5, title: "global APIs", match: function (id, module, section, item, subItem) { return (id.match(GLOBALS) || id.match(MODULE_MOCK)); } } } }, ui_resources : { js : ['resources/ui/api_ui_behavior.js'], css : ['resources/ui/api_ui_styles.css'] }, parse : { //we need to run it through our special markdown functions 'example' : function (text) { var self = this; self.example = self.markdown(text); } }, markdown : { /*=========== ANGULAR PROVIDES SPECIAL MARKDOWN SETUP FOR EXAMPLES ==========*/ 'angular' : { order: 2, markdown : function (text, placeholder) { ... } } }, /*============ THIS FUNCTION WILL DETERMINE HOW THE TITLE APPEARS AT THE TOP OF THE PAGE ============*/ //heading : function (dom) {} Let's use the one provided by the default api /*============ CUSTOM RENDER METHODS FOR USING ALL THE DOC ATTRIBUTES TO SPIT OUT HTML FOR THE PARTIALS ===========*/ html : { function: function(dom){ ... }, directive: function(dom){ ... }, filter: function(dom){ ... }, service: function(dom) { ... }, inputType: function(dom){ ... }, directiveInfo: function(dom) { ... } }, render : { // lets add another section in the partial called 'example' that adds any example 'example' : { order: 1, // you can specify an order here render: function (dom) { ... } } } };